import { Component, OnInit } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';

import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { AppService } from '../../services/app.service';
declare var $: any;

@Component({
  selector: 'app-header-plugins',
  standalone: true,
  imports: [RouterModule, 
    FormsModule,
    ReactiveFormsModule,
    CommonModule,
    HttpClientModule],
  templateUrl: './header-plugins.component.html',
  styleUrl: './header-plugins.component.scss'
})
export class HeaderPluginsComponent implements OnInit {

  public accesstoken: any;

  constructor(private appService: AppService) { }

  async ngOnInit() {
    await this.getItemAccesstoken();
    $(document).ready(() => {
      $(window).on('scroll', () => {
        if ($(window).scrollTop()) {
          $("header").addClass('bgc');
        } else {
          $("header").removeClass('bgc');
        }
      });
    });
  }

  async getItemAccesstoken() {
    this.accesstoken = await localStorage.getItem('token');
  }

  async Logout() {
    await this.appService.destroyToken();
    await window.location.reload();
  }
}
